import axios from "axios";
import NProgress from "nprogress"
import {
    getToken
} from '@/utils/token'

axios.defaults.baseURL = "/api";
//添加请求拦截器
axios.interceptors.request.use(config => {
    NProgress.start()
    config.headers['token'] = getToken();
    return config;
});
//添加响应拦截器
axios.interceptors.response.use(res => {
    NProgress.done()
    return res;
}, err => {
    //对响应错误做点什么
    return Promise.reject(err);
});
export default axios;